import {JumpMiniGameConfig} from "../../engines/configs/gameConfig";
import O1HD from "../../engines/gameEngine";

const {ccclass, property} = cc._decorator;

@ccclass
export default class cellMiniGameJump extends cc.Component {

    // LIFE-CYCLE CALLBACKS:

    // onLoad () {}

    protected start() {
        this.initView();
    }

    private m_data: JumpMiniGameConfig = null;

    setData(data: JumpMiniGameConfig) {
        this.m_data = data;
    }

    initView() {
        const data = this.m_data;
        this.node.getChildByName('name').getComponent(cc.Label).string = data.name;
        let sp = this.node.getChildByName('icon').getComponent(cc.Sprite);
        O1HD.getServices().ossSrv.showOssPathMiniGameJumpIcon(data.iconId, sp);
        this.node.on('click', () => {
            O1HD.getServices().miniGameSrv.getAppApiInstance().navigateToMiniGame(data.appId);
        });
    }

    // update (dt) {}
}
